from BasePage import Action
from utils.Yamlutil import YamlReader
from appium import webdriver
import time

# 继承Action
class CapsTest(Action):
    # 初始化WebDriver
    def __init__(self):
        desired = YamlReader("conf/appium_config.yaml").read_data()
        driver = webdriver.Remote("http://localhost:4723/wd/hub", desired)
        super().__init__(driver)

    # 登录方法, 封装click, send_keys
    def login_test(self):
        # me_path = "//android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]" \
        #           "/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.widget.ImageView[3]"
        self.by_xpath_click("//*[contains(@text, '我的')]")
        self.by_id_click("com.boxuegu:id/other_login_btn")
        self.by_id_click("com.boxuegu:id/user_login_view")
        self.by_id_click("com.boxuegu:id/passwordLoginTv")
        self.by_id_send_keys("com.boxuegu:id/edit_usr", "13333333")
        self.by_id_send_keys("com.boxuegu:id/edit_pwd", "123456")
        self.by_id_click("com.boxuegu:id/btn_login")
        toast = self.get_toast("错误")
        print(toast)


# 运行
if __name__ == '__main__':
    cap_test = CapsTest()
    cap_test.login_test()




